<?php

if ($categories):
    ?>
<section rel="categories" class="categories box">
    <header>
        <div class="buttons buttons-small float-left">
            <?php echo anchor('admin/blog/categories/create/', lang('cat_create_title'), 'rel="categories" class="add ajax button"') ?>
        </div>
        <h3 class="spacer-bottom-half"><?php echo lang('cat_list_title'); ?></h3>

        <h3 class="form-title"></h3>
    </header>

    <?php 
    if (!empty($categories)): ?>

        <div class="box-container collapsed">

            <div id="cat-list">
                <ol class="sortable">
                    <?php foreach ($categories as $category): ?>
									<li id="category_<?php echo $category['id']; ?>">
										<div>
                                            <a href="#" rel="categories"
                                               alt="<?php echo $category['id']; ?>"><?php echo $category['title']; ?></a>
                                        </div>
                    <?php

                    if (!empty($category['children'])): ?>
                        <ol>
                            <?php tree_builder($category, 'category'); ?>
                        </ol>
									</li>
								<?php
 else: ?>
                        </li>
                        <?php
                                endif; ?>

                    <?php
                        endforeach; ?>

                </ol>
            </div>

            <div id="cat-details" class="categories">
                <p>
                    <?php echo lang('cat_tree_explanation'); ?>
                </p>
            </div>
            <br class="clear-both"/>

        </div>

        <?php
         else: ?>
        <div class="box-container collapsed">

            <div id="cat-list" class="empty">
                <ol class="sortable">

                    <p><?php echo lang('cat_no_categories'); ?></p>

                </ol>
            </div>

            <div id="cat-details" class="group-<?php echo $group->id; ?>">

                <p>
                    <?php echo lang('cat_tree_explanation'); ?>
                </p>

            </div>

            <br class="clear-both"/>

        </div>
        <?php
            endif; ?>

</section>
<?php
 else: ?>
<div class="blank-slate">
    <h2><?php echo lang('cat_no_categories'); ?></h2>
</div>
<?php
endif; ?>